/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 input_manager.hh                                          VLC Gtkmmm gui module
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Copyright © 2006-2008 the VideoLAN team

 Authors: David GUGLIELMI <raxxx.fr@gmail.com>
          David LARROQUE <david.larroque@gmail.com>

 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation; either version 2 of the License, or (at your option) any later
 version.

 This program is distributed in the hope that it will be useful, but WITHOUT ANY
 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE. See the GNU General Public License for more details.

 You should have received a copy of the GNU General Public License along with
 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 Street, Fifth Floor, Boston MA 02110-1301, USA.
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

#ifndef __INPUT_MANAGER_HH_
#define __INPUT_MANAGER_HH_

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <glibmm.h>

#include "gtkmm.hh"


//FIXME Add GTK events and event class

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class InputManager
{

public:

  InputManager (intf_thread_t *);
  virtual ~InputManager ();

  void del_input ();
  bool has_input () {return p_input && !p_input->b_dead &&\
                    vlc_object_alive (p_input);}
  bool has_audio ();
  bool has_video ();

  void set_input (input_thread_t *); // Our controlled input changed
  void slider_update (float); // User dragged the slider. We get new pos
  void toggle_play_pause ();
  void slower ();
  void faster ();
  void normal_rate ();
  void set_rate (int);
  void section_next ();
  void section_prev ();
  void section_menu ();
  void telex_goto_page (int); // Goto teletext page
  void telex_toggle (bool);  // Enable disable teletext buttons
  void telex_toggle_buttons (); // Toggle buttons after click
  void telex_set_transparency (); // Set transparency on teletext background

  // Send new position, new time and new length
  void position_updated (float , int, int);
  void rate_changed (int);
  void name_changed (Glib::ustring name); //FIXME
  // Used to signal whether we should show navigation buttons
  void navigation_changed (int);
  // Play/pause status
  void status_changed (int);
  void art_changed (Glib::ustring art); //FIXME
  // Controll of fullscreen controller
  void input_unset ();
  // Teletext
  void teletext_enabled (bool);
  void toggle_telex_buttons ();
  void toggle_telex_transparency ();
  void set_new_telex_page (int);

private:

  intf_thread_t  *p_intf;
  input_thread_t *p_input;
  int i_input_id;
  int i_old_playing_status;
  Glib::ustring old_name;
  Glib::ustring art_url;
  int i_rate;
  bool b_transparent_telextext;

  // FIXME void customEvent (QEvent *);
  void add_callbacks ();
  void del_callbacks ();
  void update_rate ();
  void update_meta ();
  void update_status ();
  void update_navigation ();
  void update_position ();
  void update_spu ();
  void update_teletext ();
  void update_art ();

};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class MainInputManager
{

public:

  static MainInputManager *getInstance (intf_thread_t *_p_intf)
  {
    if (!instance)
      instance = new MainInputManager (_p_intf);
    return instance;
  }

  static void killInstance ()
  {
    if (instance) delete instance;
  }

  virtual ~MainInputManager ();

  input_thread_t *get_input () {return p_input;};
  InputManager *get_im () {return im;};

private:

  MainInputManager (intf_thread_t *);
  //FIXME void CustomEvent (

  InputManager *im;
  input_thread_t *p_input;

  intf_thread_t *p_intf;
  static MainInputManager *instance;

  bool teletext_state ();
  void toggle_play_pause ();
  void stop ();
  void next ();
  void prev ();
  void input_changed (input_thread_t *);

};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#endif /* __INPUT_MANAGER_HH_ */
